package cn.slt.controller;

import java.util.Date;
import java.sql.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.slt.domian.MD_ClassDSID;
import cn.slt.domian.MD_ObjDSID;
import cn.slt.service.MD_ObjDSIDService;
import cn.slt.service.MD_classDSIDService;

@Controller

public class MD_classDSID {
	
	@Autowired
	private MD_classDSIDService service;
	@RequestMapping("updateclass_lzd")
	@ResponseBody
	
	public String updateclass(@RequestParam String bm,@RequestParam String keywords,@RequestParam String beizhu){
		
		boolean mark=false;
		String words=null;
		
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 
		
	//	dsname=dsname.toUpperCase();
		MD_ClassDSID obj=new MD_ClassDSID();
		obj.setBeizhu(beizhu);
		obj.setKeywords(keywords);
//		try {
//			Date date=sdf.parse(builddate);
//			Date date2=new java.sql.Date(date.getTime());
//			obj.setBuildDate(date2);
//		} catch (ParseException e) {
//			e.printStackTrace();
//			return "2";
//		}
		if (!bm.equals("")){
			obj.setDsName(bm.toUpperCase());
		}
		//System.out.println(dsname.length());
		
		
		System.out.println(obj.toString());
		
		try{
			mark=service.updateclass(obj);
			System.out.println("yichang1");
			if (mark){
				words = "1";
			} else {
				words ="2";
			}
		}catch(Exception e){
			words="0";
			System.out.println("yichang");
			e.printStackTrace();
		}finally{
			return words;
		}
	}

}
